package cn.unknownerror.ueteam.gui;

import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory;

public abstract class AbstractFrame{

    protected static String identify ="§2§3§3§3§3";

    protected AbstractButton[] buttons;
    protected int size;
    protected String title;

    public AbstractFrame(int size,String title){
        this.size=size;
        this.buttons=new AbstractButton[size];
        this.title=title;
    }

    public AbstractButton getButton(int location){
        return buttons[location];
    }

    public void setButton(int location, AbstractButton button){
        buttons[location]=button;
    }

    public boolean isFrame(String title){
        return (identify+this.title).equalsIgnoreCase(title);
    }

    public Inventory createInventory(){
        Inventory inv= Bukkit.createInventory(null,size,identify+title);
        for (int i = 0; i < buttons.length; i++) {
            AbstractButton button=buttons[i];
            if(button==null){
                continue;
            }
            inv.setItem(i,button.getItem());
        }
        return inv;
    }


}
